import { BaseModel } from '@/common/base/base.model';
import { Column, Entity, Index, OneToMany } from 'typeorm';
import { BooleanNumber } from "common/utils/data";
import { ArticleModel } from "@/module/article/article.model";
import { AdminuserRoleModel } from "@/module/adminuser-role/adminuser-role.model";

@Entity('ADMIN', {
  synchronize: false,
}) // 员工（管理员）
export class AdminModel extends BaseModel {
  @Column({
    comment: '状态（1：启用，0：禁用）',
    type: 'smallint',
    default: BooleanNumber.true,
  })
  status: BooleanNumber;

  @Column({
    comment: '账户名',
    type: 'varchar',
    length: 50,
  })
  @Index('ADMIN.username', { unique: true })
  username: string;

  @Column({
    comment: '密码',
    type: 'varchar',
    length: 250,
  })
  password: string;

  @Column({
    comment: '名称',
    type: 'varchar',
    length: 50,
  })
  name: string;

  @Column({
    comment: '手机号',
    type: 'varchar',
    length: 50,
  })
  mobile: string;

  @Column({
    comment: '职位',
    type: 'varchar',
    length: 50,
  })
  job: string;

  @OneToMany(() => AdminuserRoleModel, adminuserRole => adminuserRole.admin)
  adminuserRoles: AdminuserRoleModel[];
}
